/*
 * Copyright (C) 2018 Burak Akguel, Christian Gesse, Fabian Ruhland, Filip Krakowski, Michael Schoettner
 * Heinrich-Heine University
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 */

#ifndef __InterruptHandler_include__
#define __InterruptHandler_include__

#include "kernel/threads/ThreadState.h"
#include "InterruptManager.h"

/**
 * Interface for an interrupt handler.
 * Every interrupt hanlder should dervive from this interface.
 * The trigger-method is called if an interrupt occured.
 *
 * @author Michael Schoettner, Filip Krakowski, Fabian Ruhland, Burak Akguel, Christian Gesse
 * @date HHU, 2018
 */
class InterruptHandler {
    
public:

    InterruptHandler() = default;

    InterruptHandler(const InterruptHandler &copy) = delete;

    InterruptHandler &operator=(const InterruptHandler &copy) = delete;
       
    virtual ~InterruptHandler() = default;

    /**
     * Routine to handle an interrupt. Needs to be implemented in deriving class.
     */
    virtual void trigger(InterruptFrame &frame) = 0;

    /**
     * Check, if the device has data, that must be fetched.
     */
    virtual bool hasInterruptData() {
        return false;
    }

    /**
     * Parse data that has been generated by an interrupt.
     *
     * The device is responsible for storing data, that has been generated by an interrupt.
     * If the process of parsing this data takes a long amount of time, it shall be done in
     * parseInterruptData(), which is called in a separate thread.
     */
    virtual void parseInterruptData() {};
};

#endif
